package day05_api.com.itheima.d3_method_reference;

public class Test4 {
    public static void main(String[] args) {
        Car car1 = new Create() {
            @Override
            public Car create(String name) {
                return new Car(name);
            }
        }.create("法拉利");
        System.out.println("car1 = " + car1);

        Create c3 = Car::new;
        Car car = c3.create("法拉利1");

        System.out.println("car = " + car);
    }
}

@FunctionalInterface
interface Create {
    Car create(String name);
}

class Car {
    private String name;

    public Car() {

    }

    public Car(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                '}';
    }
}
